import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)


export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/',
    component: () => import('@/views/login/index'),
    redirect: '/login',
    children: [
        // {
        // path: 'dashboard',
        // name: 'Dashboard',
        // component: () => import('@/views/dashboard/index'),
        // meta: { title: '首页', icon: 'dashboard' }
        // }
    ]
  },
]

// 声明一个方法 这个方法专门用来实例化路还有
const createRouter = () => new Router({
  mode: 'history', // require service support
  // routes: [...constantRoutes, ...asyncRoutes]
  routes: [...constantRoutes]
})

// 创建一个路由实例对象
const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
// 重置路由
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
